<?php
$this->headLink()->appendStylesheet($this->baseUrl('widget/dataTable/css/dataTables.css'));
$this->headScript()->appendFile($this->baseUrl('widget/dataTable/js/jquery.dataTables.min.js'));
$this->headScript()->appendFile($this->baseUrl('widget/dataTable/js/initDataTables.js'));


if(count($this->datos)>0):
?>
<div id="DivContenedor">
<form action="<?=$this->baseUrl("/usuarios/detalle/guardarasignarprogramas");?>" method="post">
<table id="table_id1" align="center" class="iceDatTbl zebra">
  <thead>
    <tr>
      <th width="10%">Codigo SNIES</th>
      <th width="50%">Nombre</th>
      <th width="16%">Ubicacion</th>
      <th width="4%"><input type="checkbox" value="chk_" id="chk_Todos" name="chk_Todos"></th>
    </tr>
  </thead>
  <tbody>
	<?php foreach ($this->datos as $value):?>
    <tr>
      <td style="text-align:center;"><?php echo $value["codsnies"]?></td>
      <td><?php echo App_Util_StringUtil::quitar_acentos($value["nombreprograma"])?></td>
      <td><?php echo App_Util_StringUtil::quitar_acentos($value["ubicacion"])?></td>
      <td style="text-align:center;"><input type="checkbox" name="seleccionados[]" value="<?=$value["codprograma"];?>" /></td>
    </tr>
  <?php  endforeach;?>
  </tbody>
</table>
<div align="right"><input type="submit" value="Asignar a usuario" class="iceCmdBtn" /></div>
</form>
</div>
<script type="text/javascript">
$(function() {
	var oTable = $('#table_id1').dataTable({
		"bJQueryUI": true,
		"bAutoWidth": false,
		"oLanguage": { "sUrl": baseUrl + "/widget/dataTable/lang.es.txt" },
 		"sPaginationType": "full_numbers",
 		"bStateSave": true,
 		"aoColumns": [	null,
 	 		 			null,
 	 		 			null,
 	 		 			{ "bSortable": false, "bSearchable": false }
 	 		 		 ]
 	 		  		
	});
	
	oTable.fnSetFilteringDelay();

});

$("#chk_Todos").change(function(){
	if($(this).is(":checked")) {
		$(this).closest('#DivContenedor').find('input[type=checkbox]').attr('checked', true);
	}else{
      	$(this).closest('#DivContenedor').find('input[type=checkbox]').attr('checked', false);
	}
});
</script>
<?php else:?>
<br/>
<?php echo $this->mensajes("No existen registros");?>
<?php endif;?>
